﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CH04_06
{
    class CH04_06
    {
        static int iResult = 0;
        static double dblResult = 0.0;

        static public void Add()
        {
            int iNumber1 = 10;
            int iNumber2 = 20;
            iResult = iNumber1 + iNumber2;
        }

        static public void Add(int iNum1,int iNum2)
        {
            iResult = iNum1 + iNum2;
        }

        static public void Add(int iNum1,int iNum2,int iNum3)
        {
            iResult = iNum1 + iNum2 + iNum3;
        }

        static public void Add(double dblNum1,double dblNum2)
        {
            dblResult = dblNum1 + dblNum2;
        }

        static public void Add(double dblNum1,double dblNum2,double dblNum3)
        {
            dblResult = dblNum1 + dblNum2 + dblNum3;
        }

        static void Main(string[] args)
        {
            int iResult1 = 0;
            int iResult2 = 0;
            int iResult3 = 0;
            double dblResult1 = 0.0;
            double dblResult2 = 0.0;

            Add();
            iResult1 = iResult;
            Console.WriteLine("无参数传入的两个整数相加Add()的结果:{0}", iResult1);

            Add(20, 30);
            iResult2 = iResult;
            Console.WriteLine("传入两个整数类型的参数相加Add()的结果:{0}", iResult2);

            Add(20, 30, 40);
            iResult3 = iResult;
            Console.WriteLine("传入三个整数类型的参数相加Add()的结果:{0}", iResult3);

            Add(20.5, 30.5);
            dblResult1 = dblResult;
            Console.WriteLine("传入两个浮点类型的参数相加Add()的结果:{0}", dblResult1);

            Add(20.5, 30.5, 40.5);
            dblResult2 = dblResult;
            Console.WriteLine("传入三个浮点类型的参数相加Add()的结果:{0}", dblResult2);
        }
    }
}
